﻿CREATE PROCEDURE [util].[DeleteDbBackupHistory]
@DbName [sysname]
AS
BEGIN
	SET NOCOUNT ON

	IF DB_ID(@DbName) IS NULL
		RETURN(0)

	DELETE [msdb].dbo.backupfile
	FROM [msdb].dbo.backupfile AS bf
	INNER JOIN [msdb].dbo.backupset AS bs
		ON (bs.[backup_set_id] = bf.[backup_set_id])
		AND(bs.[database_name] = @DbName)

	DELETE [msdb].dbo.backupset
	FROM [msdb].dbo.backupset
	WHERE ([database_name] = @DbName)

	RETURN(0)
END